﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using HotelG11.Models;

namespace HotelG11.Controllers
{
    public class AccountsController : Controller
    {
        //
        // GET: /Accounts/
        public ActionResult Index()
        {
            return View();
        }

        public ActionResult Login(string username, string password)
        {
            G11KhachSanEntities G11 = new G11KhachSanEntities();
            List<G11_LoaiNhanVien> acc = new List<G11_LoaiNhanVien>();
            try
            {
                var res = G11.sp_DangNhapNV(username, password);

                acc = res.ToList<G11_LoaiNhanVien>();

                Session["LoaiTK"] = acc[0].maLoaiNV;
                Session["TenLoaiTK"] = acc[0].tenLoaiNV;
            }
            catch (Exception ex)
            {
                Response.Redirect("./index");
            }
            /*    string tk;
                //Dang nhap
                G11KhachSanEntities G11 = new G11KhachSanEntities();
                try
                {
                    tk = G11.sp_DangNhap(username, password).First();
                    if (tk.Length > 0)
                    {
                        Session["TK"] = tk;
                    }
                    tk = "f";
                }
                catch (Exception e)
                {
                    tk = "f";
                }*/
            ViewBag.TT = acc;
            return View();
        }

    }
}
